package controller;

import entity.MoralScores;
import service.MoralScoresService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController
@RequestMapping("/api/moralscores")
public class MoralScoresController {

    @Autowired
    private MoralScoresService moralScoresService;

    @GetMapping("/{id}")
    public MoralScores getById(@PathVariable Integer id) {
        return moralScoresService.selectById(id);
    }

    @GetMapping("/all")
    public List<MoralScores> getAll() {
        return moralScoresService.selectAll();
    }

    @GetMapping("/student/{studentId}")
    public List<MoralScores> getByStudentId(@PathVariable Integer studentId) {
        return moralScoresService.selectByStudentId(studentId);
    }
    @PostMapping
    public int create(@RequestBody MoralScores obj) {
        return moralScoresService.create(obj);
    }

    @PutMapping
    public int update(@RequestBody MoralScores obj) {
        return moralScoresService.update(obj);
    }

    @DeleteMapping("/{id}")
    public int delete(@PathVariable Integer id) {
        return moralScoresService.delete(id);
    }
}